package fitness;

import java.text.DecimalFormat;
import optimizers.ganeat.xor.ConstantsXOR;

import util.MyUtil;

public class XORResult extends FitnessResult {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public double test1 = ConstantsXOR.conc_low;
	public double test2 = ConstantsXOR.conc_high;
	public double test3 = ConstantsXOR.conc_high;
	public double test4 = ConstantsXOR.conc_low;

	@Override
	public double finalResult() {
		double change1 = Math.max(0, test1 - ConstantsXOR.conc_low);
		double change2 = Math.max(0, ConstantsXOR.conc_high - test2);
		double change3 = Math.max(0, ConstantsXOR.conc_high - test3);
		double change4 = Math.max(0, test4 - ConstantsXOR.conc_low);
		return 1 / (0.1 + change1 + change2 + change3 + change4);
	}

	@Override
	public String toString() {
		double change1 = Math.max(0, test1 - ConstantsXOR.conc_low);
		double change2 = Math.max(0, ConstantsXOR.conc_high - test2);
		double change3 = Math.max(0, ConstantsXOR.conc_high - test3);
		double change4 = Math.max(0, test4 - ConstantsXOR.conc_low);
		return common.Static.df4.format(finalResult()) + "= 1 / (0.1 + "
				+ common.Static.df4.format(change1) + "+"
				+ common.Static.df4.format(change2) + "+"
				+ common.Static.df4.format(change3) + "+"
				+ common.Static.df4.format(change4) + ")";
	}

	@Override
	public Double[] getDecomposition() {
		double change1 = Math.max(0, test1 - ConstantsXOR.conc_low);
		double change2 = Math.max(0, ConstantsXOR.conc_high - test2);
		double change3 = Math.max(0, ConstantsXOR.conc_high - test3);
		double change4 = Math.max(0, test4 - ConstantsXOR.conc_low);
		return new Double[] { change1, change2, change3, change4 };
	}

	@Override
	public boolean goodSolution() {
		// TODO Auto-generated method stub
		return false;
	}

}
